<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: blog_item_list.php 11 2013-09-21 11:43:11Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 11 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 11:43:11 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

$status[] = array('id' => 0, 'text' => TABLE_FOOTER_STATUS_0);
$status[] = array('id' => 1, 'text' => TABLE_FOOTER_STATUS_1);
$status[] = array('id' => 2, 'text' => TABLE_FOOTER_STATUS_2);
$status[] = array('id' => 3, 'text' => TABLE_FOOTER_STATUS_3);

echo '<a href="blog.php?'.getMenuID('blog').'" class="button">zur&uuml;ck zur Kategorie</a> <a class="button" href="blog.php?action=new_item&cat='.$_GET['cat'].'&'.getMenuID('blog').'">neuen Beitrag verfassen</a><br /><br />';

$categorie = $db->db_query("SELECT
								titel
							FROM
								".TABLE_BLOG_CATEGORIES."
							WHERE
								categories_id = '".(int)$_GET['cat']."'
							AND
								language_id = '".$_SESSION['languages_id']."'");

echo draw_form('leiste', FILENAME_BLOG, 'action=set&cat='.(int)$_GET['cat']);?>
<script type="text/javascript">
	<!--
		function loadItems(id, lng, action) {
			if($('#all_comments_'+id).length < 1) {
				showOverlay('.dataTable');
				xajax_blogAction(id, lng, action);
			} else {
				$('#all_comments_'+id).fadeOut(900, function(){$(this).remove()});
			}
		}
	//-->
</script>
<table width="100%" border="0" cellspacing="1" cellpadding="3" class="dataTable">
	<tr class="dataTableHeadingRow">
		<th class="dataTableHeadingContent" width="5%" align="center"><input type="checkbox" onclick="checkboxes(this.checked);"></td>
		<th class="dataTableHeadingContent" width="70%" align="left"><b>Kategorie: <em><?php echo $categorie->fields['titel'];?></em></b></td>
		<th class="dataTableHeadingContent" width="5%"><b><?php echo TABLE_HEADING_NEWCATEGORIE_POSITION;?></b></td>
		<th class="dataTableHeadingContent" width="5%">Angezeigt</b></td>
		<th class="dataTableHeadingContent" width="10%"><b>erstellt am</b></td>
		<th class="dataTableHeadingContent" width="10%" align="left"><b><?php echo TABLE_HEADING_ACTION;?></b></td>
	</tr>
<?php
	$items = $db->db_query("SELECT
								item_id,
								name,
								status,
								position,
								DATE_FORMAT(date, '%d.%m.%Y %H:%i Uhr') AS date,
								shown
							FROM
								".TABLE_BLOG_ITEMS."
							WHERE
								categories_id = '".$_GET['cat']."'
							AND
								language_id = '".$_SESSION['languages_id']."'
							ORDER BY
								position ASC ");
	if($items->_numOfRows) {
		$i = 0;
		while(!$items->EOF){
		?>
			<tr id="blog_item_<?php echo $items->fields['item_id'];?>" class="<?php echo (($i%2==0) ? 'dataTableRow' : '');?>">
				<td align="center">
					<?php echo draw_selection_field('status[]', 'checkbox', $items->fields['item_id']);?>
				</td>
				<td>
					<?php 
					echo '<span id="item_'. $items->fields['item_id'].'" onclick="loadItems('.$items->fields['item_id'].',\'com\','.$_SESSION['languages_id'].')">
						<img style="position:relative;top:4px;cursor:pointer" src="'.DIR_WS_ICONS.'balloons.png" alt="Zeige Kommentare" />
					</span> '.($items->fields['status'] == 0 || $items->fields['status'] == 1 ? '<span style="color:#b20000">'.$items->fields['name'].' - Offline</span>' : $items->fields['name']);?></td>
				<td align="center"><?php echo $items->fields['position'];?></td>
				<td align="center"><?php echo $items->fields['shown'];?>x</td>
				<td align="center"><nobr><?php echo $items->fields['date'];?></nobr></td>
				<td>
					<a href="<?php echo href_link(FILENAME_BLOG, 'action=edit_item&cat='.$_GET['cat'].'&item='.$items->fields['item_id']);?>">
						<?php echo image(DIR_WS_ICONS.'edit.gif', TABLE_HEADING_ACTION_EDIT);?>
					</a>
				</td>
			</tr>
			<?php
			$i++;
			$items->MoveNext();
		}

	} else {
		echo '<tr><td colspan="5" valign="center" align="center"><b>Derzeit sind keine Beitr&auml;ge vorhanden.</b></td></tr>';
	}
?>
</table>
<table width="100%" border="0" cellspacing="1" cellpadding="3">
  <tr>
		<td class="uni_header" width="70" align="center"><?php echo TABLE_FOOTER_STATUS;?>
		<td class="uni_header" width="70" align="center"><?php echo draw_pull_down_menu('set_item_status', $status, '', 'style="width:100px;"');?></td>
		<td class="uni_header" width="50" align="center">
			<button type="submit" class="button">Status &auml;ndern</button>
		</td>
		<td class="uni_header">&nbsp;</td>
	</tr>
</table>
</form>